package org.muses.ssm.senior.mgt.demo.entity;

import java.util.HashMap;
import java.util.Map;

public class MusesResult {

	// 状态码
	private int code;

	// 消息
	private String msg;

	// 返回数据
	private Map<String, Object> context = new HashMap<String, Object>();

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Map<String, Object> getContext() {
		return context;
	}

	public void setContext(Map<String, Object> context) {
		this.context = context;
	}

	public static MusesResult success() {
		MusesResult musesResult = new MusesResult();
		musesResult.setCode(200);
		musesResult.setMsg("处理成功");
		return musesResult;
	}

	public static MusesResult success(String msg, Object obj) {
		MusesResult musesResult = new MusesResult();
		musesResult.setCode(200);
		musesResult.setMsg(msg);
		Map<String, Object> context = new HashMap<String, Object>();
		context.put("data", obj);
		musesResult.setContext(context);
		return musesResult;
	}

	public static MusesResult fail() {
		MusesResult musesResult = new MusesResult();
		musesResult.setCode(500);
		musesResult.setMsg("处理失败");
		return musesResult;
	}

	public static MusesResult fail(String msg) {
		MusesResult musesResult = new MusesResult();
		musesResult.setCode(500);
		musesResult.setMsg(msg);
		return musesResult;
	}
}
